package com.hillstone.hsm.swtool.shellp.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hillstone.hsm.swtool.shellp.common.AjaxResult;
import com.hillstone.hsm.swtool.shellp.db.mapper.UserMapper;
import com.hillstone.hsm.swtool.shellp.model.User;

@Service
public class UserService {

	//@Autowired
	private UserMapper userMapper;

	public AjaxResult queryList() {
//		List<User> list = userMapper.queryList();
		List<User> list = new ArrayList<>();
		User u1 = new User();
		u1.setId(1);
		u1.setUsername("张三");
		u1.setUseable(1);
		u1.setAddtime(new Date().toString());
		u1.setEmail("zhangsan@126.com");
		u1.setLoginip("1.1.1.1");
		u1.setLogintime(new Date().toString());
		u1.setPassword("hillstone");
		list.add(u1);
		return new AjaxResult(list);
		
	}

	public AjaxResult save(User user) {
		user.setUsername("user" + System.currentTimeMillis());
		user.setPassword("123456");
		user.setEmail("user" + System.currentTimeMillis());
		user.setUseable(1);
		userMapper.save(user);
		return new AjaxResult();
	}

	public AjaxResult batchDelete(Integer[] ids) {
		userMapper.batchDelete(ids);
		return new AjaxResult();
	}

	public AjaxResult update(User user) {
		userMapper.update(user);
		return new AjaxResult();
	}

}